import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import WindiCSS from 'vite-plugin-windicss'
import path from 'path';

// https://vitejs.dev/config/
export default defineConfig({
  server: {
    host: '0.0.0.0',  // 监听所有IP
    port: 5173,       // 端口号
    open: true,       // 可选：启动后自动在浏览器中打开
    strictPort: true, // 可选：如果端口被占用则报错
    proxy: {
      '/api': {
        target: 'http://47.110.48.101:8888',
        // target: 'http://192.168.110.219:8888',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ''),
      },
      '/projects': {
        target: 'http://47.110.48.101:8889',
        // target: 'http://192.168.110.219:8889',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/projects/, ''),
      },

      '/results': {
        target: 'http://47.110.48.101:8893',
        // target: 'http://192.168.110.219:8893',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/results/, ''),
      },

      // '/api': {
      //   target: 'http://47.99.241.61:8888',
      //   changeOrigin: true,
      //   configure: (proxy, options) => {
      //     // proxy 是 'http-proxy' 的实例
      //   }
      // },
    }
  },
  plugins: [vue(), WindiCSS()],
  resolve: {
    alias: {
      '~': path.resolve(__dirname, 'src'),

    },
  },
})
